from datetime import datetime

from django.db import models
from django.contrib.auth.models import AbstractUser


# Create your models here.
class UserProfile(AbstractUser):
    """
    用户模型类
    """
    gender_choices = (
        ('male', '男'),
        ('female', '女'),
        ('secret', '保密'),
    )
    name = models.CharField(max_length=30, null=True, blank=True, verbose_name='姓名')
    birthday = models.DateField(null=True, blank=True, verbose_name='生日')
    gender = models.CharField(max_length=6, choices=gender_choices, default='secret', verbose_name='性别')
    mobile = models.CharField(null=True, blank=True, max_length=11, verbose_name='手机号码')
    email = models.EmailField(max_length=100, null=True, blank=True, verbose_name='邮箱')
    # address = models.CharField(max_length=255, verbose_name='地址')
    # image = models.ImageField(upload_to='user_image', verbose_name='头像')
    # is_staff = models.BooleanField()

    class Meta:
        verbose_name = '用户'
        verbose_name_plural = verbose_name

    def _str_(self):
        return self.name


class VerifyCode(models.Model):
    """
    验证码
    """
    code = models.CharField(max_length=10, verbose_name='验证码')
    mobile = models.CharField(max_length=11, verbose_name='手机号码')
    add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间")

    class Meta:
        verbose_name = '短信验证码'
        verbose_name_plural = verbose_name

    def _str_(self):
        return self.code